package DengLu;

import java.sql.*;
import java.util.Scanner;

public class DengLu1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入用户名");
        String name = scanner.next();
        System.out.println("请输入密码");
        int password = scanner.nextInt();
        //加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql:///test2", "root", "root");
       //获取语句执行者
        Statement statement = connection.prepareStatement("select * from user where zhanghuming= ? and password=? ");
        //编写sql语句

        //执行sql语句
       // ResultSet resultSet3 = statement.executeQuery();
        //判断用户存在
//        if(resultSet3.next()){
//            System.out.println("恭喜您登陆成功呢");
//
//        }else{
//            System.out.println("用户名密码错误");
//        }
        //关流
        statement.close();
        connection.close();

    }
}
